package com.iphanta.community.following.web;

import com.iphanta.community.common.entity.DataResult;
import com.iphanta.community.common.utils.ResultUtils;
import com.iphanta.community.following.service.FollowingService;
import com.iphanta.community.following.traffic.FollowRequest;
import com.iphanta.community.following.traffic.FollowResponse;
import com.iphanta.community.following.traffic.FollowingsFollowersRequest;
import com.iphanta.community.following.traffic.FollowingsFollowersResponse;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 关注功能
 *
 * @author 墨声 E-mail: zehong.hongframe.huang@gmail.com
 * create time: 2/11/22 7:22 PM
 */
@Api(tags = "关注功能")
@RestController
@RequestMapping("community/following")
public class FollowingController {

    private static final Logger LOGGER = LoggerFactory.getLogger(FollowingController.class);

    @Autowired
    private FollowingService followingService;

    /**
     * 关注
     *
     * @param request
     * @return
     */
    @PostMapping("follow")
    public DataResult<FollowResponse> follow(@RequestBody FollowRequest request) {
        return ResultUtils.SUCCESS.result(this.followingService.follow(request));
    }

    /**
     * 取消关注
     *
     * @param request
     * @return
     */
    @PostMapping("unfollow")
    public DataResult<FollowResponse> unfollow(@RequestBody FollowRequest request) {
        return ResultUtils.SUCCESS.result(this.followingService.unfollow(request));
    }

    /**
     * 关注列表
     *
     * @param request
     * @return
     */
    @PostMapping("followings")
    public DataResult<FollowingsFollowersResponse> followings(@RequestBody FollowingsFollowersRequest request) {
        return ResultUtils.SUCCESS.result(this.followingService.followings(request));
    }

    /**
     * 粉丝列表
     *
     * @param request
     * @return
     */
    @PostMapping("followers")
    public DataResult<FollowingsFollowersResponse> followers(@RequestBody FollowingsFollowersRequest request) {
        return ResultUtils.SUCCESS.result(this.followingService.followers(request));
    }

}
